﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 战棋模拟器
{
    class 玛尔加尼斯:Minion
    {
        public 玛尔加尼斯() : base()
        {
            buff = 2;
            Star = 5;
            Health = 7;
            Attack = 9;
            Race = race.devil;
        }


        public override void Initialize()
        {
            foreach (Minion m in pool.places)
            {
                if (m == null)
                    break;
                if (m != this)
                    if (m.Race == race.devil || m.Race == race.all)
                    {
                        m.Attack += buff;
                        m.Health += buff;
                        m.fullHealth += buff;
                    }
            }
            base.Initialize();
        }


        public override void OnSpawn(Minion m)
        {
            if ((m.Race == race.devil || m.Race == race.all) && m != this)
            {
                m.fullHealth += buff;
                m.Health += buff;
                m.Attack += buff;
            }
        }


        public override void Die()
        {
            foreach (Minion m in pool.places)
            {
                if (m == null)
                    break;
                if ((m.Race == race.devil || m.Race == race.all) && m != this)
                {
                    m.Attack -= buff;
                    m.fullHealth -= buff;
                    if (m.Health > m.fullHealth)
                        m.Health = m.fullHealth;

                    //以下代码弃用，
                    //不准确，可能以后需要重写
                    //int full = m.NewOne().Health;
                    //if (m.Health - full > buff)
                    //    m.Health -= buff;
                    //else if (m.Health > full)
                    //    m.Health = full;
                }
            }
            base.Die();
        }


        public override Minion NewOne()
        {
            return new 玛尔加尼斯();
        }
    }


    class 玛尔加尼斯_金色 : 玛尔加尼斯
    {
        public 玛尔加尼斯_金色() : base()
        {
            Attack *= 2;
            Health *= 2;
            count *= 2;
            buff *= 2;
        }

        public override Minion NewOne()
        {
            return new 玛尔加尼斯_金色();
        }
    }
}
